package com.myway.dto.product.domain;

import java.util.HashMap;

/**
 * 类名称：SupportBusinessStatus
 * 类描述：辅营订单状态
 * 创建时间：2016-1-13 上午10:16:46
 * @author jiangyang
 * @version V1.0
 */
public enum SupportBusinessStatus{
	
	BH("BH"), // 未支付

	XI("XI"), //取消中
	
	XX("XX"), // 已取消
	
	BO("BO"), //支付完成
	
	BF("BF"), // 购买成功
	
	RH("RH"), // 退单中
	
	RF("RF"), // 退单完成

	RC("RC"), //退款完成
	
	RL("RL"), //退款失败
	
	OH("OH"),//单独退单处理中
	OC("OC"),//单独退单审核通过
	OF("OF"),//单独退单成功
	
	SS("SS"), //暂停使用
	SB("SB");//购买失败

	/**
	 * Alias name. This is the name which will be stored in database.
	 */
	private final String alias;

	/**
	 * A hash map which keep all the action enum with alias name as key.
	 */
	private static HashMap<String, SupportBusinessStatus> map;

	/**
	 * Construct the hash map at load time
	 */
	static
	{
		map = new HashMap<String, SupportBusinessStatus>();
		for ( SupportBusinessStatus type : SupportBusinessStatus.values() )
		{
			map.put( type.alias, type );
		}
	}

	SupportBusinessStatus(String alias)
	{
		this.alias = alias;
	}

	@Override
	public String toString()
	{
		return this.alias;

	}

	/**
	 * Return a <code>Action</code> object holding the value of specified alias name
	 * 
	 * @param alias
	 * the alias name of the type
	 * 
	 * @return a <code>Action</code> object holding the value represented by the alias name argument
	 */
	public static SupportBusinessStatus valueOfAlias(String alias)
	{
		SupportBusinessStatus type = map.get( alias );

		if ( type == null )
		{
			throw new IllegalArgumentException( "Unknown action alias [" + alias + "]" );
		}

		return type;
	}

	/**
	 * @return the alias
	 */
	public String getAlias()
	{
		return this.alias;
	}

}
